package com.yenlien.traceyun.control.controller;

import com.yenlien.traceyun.control.entity.StoreOrder;
import com.yenlien.traceyun.control.interceptor.UserAuthUtil;
import com.yenlien.traceyun.control.service.StoreOrderService;
import com.yenlien.traceyun.webase.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author jialong
 * @date 2021/06/01
 * @description:
 **/
@RestController
@RequestMapping("/storeOrder")
public class StoreOrderController extends BaseController {

    @Autowired
    private StoreOrderService storeOrderService;


    @PostMapping(value = "/save")
    public Object save(@RequestBody StoreOrder storeOrder) {
        storeOrder.setCompanyId(UserAuthUtil.getLoginUser().getCompanyId());
        return success(storeOrderService.save(storeOrder));
    }


    @GetMapping(value = "/findById")
    public Object findById(String id) {
        return success(storeOrderService.findById(id));
    }

    @PostMapping(value = "/findList")
    public Object findByList(@RequestBody StoreOrder storeOrder) {
        return buildPage(storeOrderService.findByList(storeOrder));
    }

    @GetMapping(value = "/getAllPositions")
    public Object getAllPositions() {
        return success(storeOrderService.getAllPositions(UserAuthUtil.getLoginUser().getCompanyId()));
    }


    @GetMapping(value = "/getShelvesByPosition/{positionId}")
    public Object getShelvesByPosition(@PathVariable("positionId") Long positionId) {
        return success(storeOrderService.getShelvesByPosition(positionId));
    }

    @GetMapping(value = "/getGoodsBySId/{shelvesId}")
    public Object getGoodsBySId(@PathVariable("shelvesId") Long shelvesId) {
        return success(storeOrderService.getGoodsBySId(shelvesId));
    }


}
